# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=nano
pkgver=2.4.3
pkgrel=1
pkgdesc="Pico editor clone with enhancements"
arch=('i686' 'x86_64')
license=('GPL')
url="http://www.nano-editor.org"
groups=('editors')
depends=('ncurses' 'sh')
makedepends=('make'
             'automake-wrapper'
             'ncurses-devel'
             'libiconv-devel'
             'gettext-devel')
backup=('etc/nanorc')
install=nano.install
source=(http://www.nano-editor.org/dist/v2.4/${pkgname}-${pkgver}.tar.gz
        2.2.4-wchar.patch
        nano-2.3.4-fix-ncurses-location.patch
        nano-2.3.2-msys2.patch)
md5sums=('0acc0ca68eee68ef38f899532a4873c6'
         '85fd83d3de15f8820bec392a0a938274'
         '115d59c70211cafa25c468a67586b427'
         '8bb4295dcd8d024a20f75137da16aa61')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p2 -i ${srcdir}/2.2.4-wchar.patch
  patch -p1 -i ${srcdir}/nano-2.3.4-fix-ncurses-location.patch
  patch -p1 -i ${srcdir}/nano-2.3.2-msys2.patch
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure --build=${CHOST} \
    --prefix=/usr \
    --sysconfdir=/etc \
    --enable-color \
    --without-slang \
    --enable-nanorc \
    CFLAGS="${CFLAGS} -I/usr/include/ncursesw" \
    CPPFLAGS="${CPPFLAGS} -I/usr/include/ncursesw"

  make
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  install -DTm644 ${srcdir}/${pkgname}-${pkgver}/doc/nanorc.sample ${pkgdir}/etc/nanorc
}
